package result;

import lombok.Data;

@Data
public class Result<T> {

    private String message;
    private Integer code;
    private T data;
    private static final Integer SUCCESS_CODE = 200;
    private static final Integer BAD_REQUEST =201;

    public static Result success() {
        return new Result(SUCCESS_CODE);
    }

    public static <T> Result<T> success(T data) {
        return new Result<T>(data);
    }

    public static Result fail(String message) {
        return new Result(message);

    }

    public static Result fail(String message, Integer code) {
        return new Result(message);

    }

    public Result(String message) {
        this.message = message;
        this.code = BAD_REQUEST;

    }

    public Result(String message, Integer code) {
        this.message = message;
        this.code = code;
    }

    public Result(T data) {
        this.data = data;
    }

    public Result() {

    }

    public Result(Integer code) {
        this.code = code;
    }

}
